package com.td.framework.kqxt.pbgl.dao.impl;

import java.util.ArrayList;
import java.util.List;

import com.td.framework.common.BaseDao;
import com.td.framework.kqxt.domain.KqBcsz;
import com.td.framework.kqxt.domain.KqGlpb;
import com.td.framework.kqxt.domain.KqGlpbxx;
import com.td.framework.kqxt.pbgl.dao.GlpbDao;

public class GlpbDaoImpl extends BaseDao implements GlpbDao{
	/**
	 * 用于页面上班次下拉列表接口
	 * @return list<KqBcsz>;
	 */
	public List<KqBcsz> getAllBc(){
		String hql ="from KqBcsz";
		return this.getHibernateTemplate().find(hql);
	}
	
	/**
	 * 添加时添加规律排班详细信息
	 */
	public boolean saveOrUpdateEntity(KqGlpb glpb,List<KqGlpbxx> glpbxxList){
		boolean flag =true;
		this.getHibernateTemplate().saveOrUpdate(glpb);
		List<KqGlpbxx> newList = new ArrayList<KqGlpbxx>();
		for(KqGlpbxx glpbxx:glpbxxList){
			if(glpbxx!=null){
				glpbxx.setFkGlpb(glpb.getId());
				newList.add(glpbxx);
			}
		}
		this.getHibernateTemplate().saveOrUpdateAll(newList);
		return flag;
	}
	
	/**
	 * 根据规律排版id得到具体的规律排班详细
	 * @param id 规律排班id
	 * @return list 规律排班详细集合
	 */
	public List<KqGlpbxx> getGlpbxxList(String id){
		String hql ="from KqGlpbxx where fkGlpb='"+id+"'";
		return this.getHibernateTemplate().find(hql);
	}
}
